package com.netbliz.common.util;


public class PathUtil {

	/**
	 * 返回项目实际路径，如D:/tomcat/webapps/ROOT/
	 * @return 
	 */
	public static String getContextPath() {
		String path = PathUtil.class.getResource("PathUtil.class").getPath();
		int index = path.indexOf("WEB-INF");
		if (index < 0) {
			path = path.substring(0, path.indexOf("/com/") + 1);
		} else {
			path = path.substring(0, index);
		}
		if (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0) {
			if (path.startsWith("/")) {
				path = path.substring(1);
			} else if (path.startsWith("file:/")) {
				path = path.substring(6);
			}
		} else {
			if (path.startsWith("file:/")) {
				path = path.substring(5);
			}
		}
		path = path.replaceAll("%20", " ");
		return path;
	}
}
